import axios from "../utils/axios";

export const searchChatsRoomApi = async (name: string) => {
  return await axios.get<IConnectGroup[]>(`/chat-room/searchGroup`, {
    params: { name },
  });
};

// 加入群聊
export const joinChatsRoomApi = async (groupId: string) => {
  return await axios.get<IConnectGroup>(`/chat-room/joinGroup`, {
    params: { groupId },
  });
};

// 获取聊天室列表
export const getChatsRoomListApi = async () => {
  return await axios.get<IChats[]>(`/chat-room/getChatList`);
};

// 获取群聊列表
export const getChatsRoomGroupListApi = async () => {
  return await axios.get<IChats[]>(`/chat-room/getGroupList`);
};

// 创建一对一聊天
export const createOneToOneChatsRoomApi = async (friendId: number) => {
  return await axios.get<IChats>(`/chat-room/createOne`, {
    params: { friendId },
  });
};

// 获取群聊用户
export const getChatsRoomGroupUserApi = async (groupId: number) => {
  return await axios.get<IGroupUser[]>(`/chat-room/getGroupUser`, {
    params: { groupId },
  });
};
